package com.power.sifa.respond.model;


import com.plf.core.common.annotations.FieldEnumText;
import com.plf.core.common.domain.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.springframework.stereotype.Component;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
*  应诉机关实体类
*/

@Entity
@ApiModel(value="应诉机关")
@Data
@Table(name="Apl_organ",schema="sfapprove")
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Component
//@IdClass(Apl_organ.Apl_organPK.class) 用于复合组件
public class Apl_organ extends BaseModel implements Serializable {

	private static final long serialVersionUID = 1L;

    @Id
    @Setter(AccessLevel.NONE)
    @ApiModelProperty(value = "applyid+nanoid")
    private String id;

    @ApiModelProperty(value = "applyid")
    private String applyid;

    @ApiModelProperty(value = "顺序号")
    private Integer sortnum;

    @ApiModelProperty(value = "应诉机关类型")
    private Integer type;

    @ApiModelProperty(value = "应诉机关级别")
    private Integer level;

    @ApiModelProperty(value = "机关名称")
    private String name;

    @ApiModelProperty(value = "是否委托代理人")
    private Integer isagent;

    @ApiModelProperty(value = "代理人类型")
    private Integer agenttype;

    @ApiModelProperty(value = "其他")
    private String other;

    /**
     *  应诉机关类型文本
     */
    @Transient
    @FieldEnumText(eum="Tp_organ", valuefield="type")
    private String type_text;

    /**
     *  应诉机关级别文本
     */
    @Transient
    @FieldEnumText(eum="Tp_level", valuefield="level")
    private String level_text;

    /**
     *  是否委托代理人文本
     */
    @Transient
    @FieldEnumText(eum="yesNo", valuefield="isagent")
    private String isagent_text;

    /**
     *  代理人类型文本
     */
    @Transient
    @FieldEnumText(eum="Tp_agent", valuefield="agenttype")
    private String agenttype_text;


    public Map<String, Object> parseMap() {
        Map<String, Object> map=new HashMap<>();
        map.put("id", this.getId());
        map.put("applyid", this.getApplyid());
        map.put("sortnum", this.getSortnum());
        map.put("type_text", this.type_text);
        map.put("type", this.getType());
        map.put("level_text", this.level_text);
        map.put("level", this.getLevel());
        map.put("name", this.getName());
        map.put("isagent_text", this.isagent_text);
        map.put("isagent", this.getIsagent());
        map.put("agenttype_text", this.agenttype_text);
        map.put("agenttype", this.getAgenttype());
        map.put("other", this.getOther());
        return map;
    }

    public String getId() {
        return id;
    }

    public void setId(Serializable id) {
        this.id = (String) id;
    }

    public Serializable getPrimaryKey() {
        return id;
        // return new Apl_organPK(id, id2); 用于复合主键，请手动创建内部静态类
    }

    public void setPrimaryKey(Serializable key) {
        this.id = (String)key;

        //Apl_organPK pk = (Apl_organPK) key; 用于复合主键
        //this.id = pk.getId();
        //this.id2 = pk.getId2();
    }

}
